package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteActivitiService;
import com.ruoyi.system.api.domain.ActKeyPage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 模板key页面id关联服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteActivitiFallbackFactory implements FallbackFactory<RemoteActivitiService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteActivitiFallbackFactory.class);

    @Override
    public RemoteActivitiService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteActivitiService()
        {
            @Override
            public R<List<ActKeyPage>> listNoPaging(ActKeyPage actKeyPage)
            {
                return R.fail("获取模板key页面id关联列表失败:" + throwable.getMessage());
            }

            @Override
            public R<Map<String, Object>> submitApplyByMap(Map<String, Object> map) {
                return R.fail("获取当前工作流实例id关联列表失败:" + throwable.getMessage());
            }

            @Override
            public R<Map<String, Object>> richProcessFieldByMap(Map<String, Object> map) {
                return R.fail("填充流程相关字段失败:" + throwable.getMessage());
            }

            @Override
            public R<Map<String, Set<String>>> activitiReminder(Integer hour) {
                return R.fail("获取所有需要被提醒的用户和角色失败:" + throwable.getMessage());
            }


        };
    }
}
